import MySQL

table_mapper = {
    "students":"students_new"
}



def compare_data(old_data,new_data):
    for old,new in zip(old_data,new_data):
        for filed in old.keys():
            old_value = old[filed] #旧表里面的值
            new_value = new[filed] #新表里面的值
            if new_value != old_value:
                print("发现一条不一致的数据:id是%s,字段是 %s" % (old["id"],filed) )


for old,new in table_mapper.items():
    old_sql = "select * from %s;" % old
    new_sql = "select * from %s;" % new
    old_data = MySQL.execute_sql(old_sql)
    new_data = MySQL.execute_sql(new_sql)
    compare_data(old_data,new_data)